// https://leetcode-cn.com/problems/implement-queue-using-stacks/
#include <stack>
#include <iostream>

using namespace std;

暴力解法
class MyQueue {
public:
	stack<int> in;
	stack<int> out;
    MyQueue() {

    }
	// ->3 ->2 ->1
    // 将元素 x 推到队列的末尾
    void push(int x) {
		in.push(x);
    }
    
	// 从队列的开头移除并返回元素
    int pop() {
		if(in.empty()){
			return -1;
		}
		while(!in.empty()){
			out.push(in.top());
			in.pop();
		}
		int top = out.top();
		out.pop();
		while(!out.empty()){
			in.push(out.top());
			out.pop();
		}
		return top;
    }
    
	// 返回队列开头的元素
    int peek() {
		if(in.empty()){
			return -1;
		}
		while(!in.empty()){
			out.push(in.top());
			in.pop();
		}
		int top = out.top();
		while(!out.empty()){
			in.push(out.top());
			out.pop();
		}
		return top;
    }
    
	// 如果队列为空，返回 true ；否则，返回 false
    bool empty() {
		return in.empty();
    }
};


int main(){
	MyQueue * q = new MyQueue;
	q->push(1);
	q->push(2);
	q->push(3);
	
	int a = q->pop();
	cout << "a:" << a << endl;
	int b = q->peek();
	cout << "b:" << b << endl;
	return 0;
}